<html>

<?php

$this->breadcrumbs=array(
	'Purchase'=>array('index'),
	'View Quotation',
);
$tempPO='';
$tempQuoNo='';
foreach($modelHeader as $mdlHeader){
	$tempPO= $mdlHeader->purchase_no;
	$tempQuoNo= $mdlHeader->quotation_no;
	$flagGenerate=$mdlHeader->generate;
}
$tempFullAction=true;

$this->menu=array(
	array('label'=>'List Purchase', 'url'=>array('index')),
	array('label'=>'View Quotation', 'url'=>array('quotationOrderHeader/viewQuotationOrderHeader','id'=>$tempQuoNo)),
	//array('label'=>'testing','url'=>array('#','linkOptions'=>array('onclick'=>'js:history.go(-1);returnFalse;'))),
	//array('label'=>'Add Item', 'url'=>array('purchaseorderdetail/create','quo_no'=>$tempQuoNo)),
);
?>

<h1>View Purchase Order
<?php
	if($flagGenerate==1){
		echo '<span class="label label-important"> Closed </span>';
		$tempFullAction=false;
	}
?>
</h1>

<h3>Header</h3>
<?php 
	if($flagGenerate==0){
?>
<table class='pull-right'>
	<tr>
		<td>
		<?php 
			echo CHtml::beginForm( Yii::app()->createUrl('PurchaseOrderHeader/close&id='.$tempPO));
		 	echo CHtml::submitButton('Finalize',array(
		 		'class'=>'pull-right',
			));  
			 echo CHtml::endForm();
		?>
		</td>
	</tr>
</table>
<br />
<br />
<?php } ?>


<?php
$myclass = get_class($this);
$myclass= strstr($myclass,'Controller',true);
/*$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'purchase-order-header-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		
	),
)); */

$this->widget('application.extensions.tablesorter.Sorter', array(
    'data'=>$modelHeader,
    'columns'=>array(
    	'purchase_no',
		'quotation_no',
		'quo_no.date',
		'quo_no.customer',
	),
	'filters'=>array(
        'filter-false',
		'filter-false',
        'filter-false',
        'filter-false',
    ),
	'view'=>'controllerView',
	'isViewQuotation'=>true,
	'fullAction'=>$tempFullAction,
));

?>
<!-- 
<div id="button" align="right">
<?php echo CHtml::beginForm( Yii::app()->createUrl('purchaseOrderHeader/viewPDF&id='.$tempPO)); ?>
<?php echo CHtml::submitButton('Generate',array(
   'class' => 'pull-right'
));  ?>
<?php echo CHtml::endForm(); ?> 
</div> -->

<style type="text/css">
	
	#button{
	text-align: right;
	}
		
</style>
<br />
<br/>
<h3>Detail</h3>
<?php

$myclass = get_class($this);
$myclass= strstr($myclass,'Controller',true);

$this->widget('application.extensions.tablesorter.Sorter', array(
    'data'=>$modelDetail,
    'columns'=>array(
		//'quotation_no',
		'product_pn',
		'additional',
		'qty',
		'uom',
		'products.unit_sell',
	),
	'filters'=>array(
        //'filter-false',
		'filter-select',
        'filter-false',
        'filter-false',
        'filter-select',
		'filter-false',
    ),
	'view'=>'PurchaseOrderDetail',
	'model'=>3,
	//'page'=>$myclass,
));
?>
<div class="row buttons">
<?php echo CHtml::beginForm( Yii::app()->createUrl('purchaseOrderHeader/viewPDF&id='.$tempPO)); ?>
<input type='submit' class='pull-right' onclick="this.form.target='_blank';return true;" style="margin-right:20px;" value='Generate'> 
<?php echo CHtml::endForm(); ?> 
</div>

</html>